package org.kjtc.controller;

import org.kjtc.entity.BackLog;
import org.kjtc.entity.FeedBack;
import org.kjtc.entity.UserInfo;
import org.kjtc.service.FeedBackService;
import org.kjtc.service.ReportFormService;
import org.kjtc.web.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/12/1 0001.
 */
@RestController
public class FeedBackController extends BaseController{

    @Autowired
    private FeedBackService feedBackService;

    @RequestMapping(value="searchAllFeedBack")
    public Map<String, Object> doGetFeedBackMsg(FeedBack feedBack){
        Map<String, Object> map = new HashMap<String, Object>();
        List<FeedBack> listOne = null;
        try {
            listOne =  feedBackService.doGetFeedBackMsg(feedBack);
        } catch (Exception e) {
            e.printStackTrace();
            return map;
        }
        map.put("listFeedBack", listOne);
        return map;
    }

    @RequestMapping(value = "/updateFeed")
    public Map<String, Object> updateFeed(FeedBack feedBack) {
        UserInfo userInfo= (UserInfo) this.getSession().getAttribute("userInfo");
        String userID=userInfo.getUserID();
        if(userID != null && userID != ""){
             feedBack.setCreateUser(userID);
             feedBack.setUpdateUser(userID);
        }
        Map<String, Object> map = new HashMap<String, Object>();
        int count = 0;
        try {
            count = feedBackService.updateFeed(feedBack);
            if (count > 0) {
                map.put("result", "Success");
            } else {
                map.put("result", "NotFound");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return map;
        }
        map.put("result", "Success");
        return map;
    }
}
